<form name="editForm" role="form" novalidate (ngSubmit)="save()" #editForm="ngForm">

    <div class="modal-header">
        <h4 class="modal-title" id="myCommentLabel" jhiTranslate="greatBigExampleApplicationApp.comment.home.createOrEditLabel">Create or edit a Comment</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"
                (click)="clear()">&times;</button>
    </div>
    <div class="modal-body">
        <jhi-alert-error></jhi-alert-error>
        <div class="form-group" [hidden]="!comment.id">
            <label for="id" jhiTranslate="global.field.id">ID</label>
            <input type="text" class="form-control" id="id" name="id"
                   [(ngModel)]="comment.id" readonly />
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="greatBigExampleApplicationApp.comment.body" for="field_body">Body</label>
            <textarea class="form-control" name="body" id="field_body"
                [(ngModel)]="comment.body" required ></textarea>
            <div [hidden]="!(editForm.controls.body?.dirty && editForm.controls.body?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.body?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="greatBigExampleApplicationApp.comment.createdAt" for="field_createdAt">Created At</label>
            <div class="d-flex">
                <input id="field_createdAt" type="datetime-local" class="form-control" name="createdAt" [(ngModel)]="comment.createdAt"
                required  />
            </div>
            <div [hidden]="!(editForm.controls.createdAt?.dirty && editForm.controls.createdAt?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.createdAt?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
                <small class="form-text text-danger"
                    [hidden]="!editForm.controls.createdAt?.errors?.ZonedDateTimelocal" jhiTranslate="entity.validation.ZonedDateTimelocal">
                    This field should be a date and time.
                </small>
            </div>
        </div>
        <div class="form-group">
            <label class="form-control-label" jhiTranslate="greatBigExampleApplicationApp.comment.updatedAt" for="field_updatedAt">Updated At</label>
            <div class="d-flex">
                <input id="field_updatedAt" type="datetime-local" class="form-control" name="updatedAt" [(ngModel)]="comment.updatedAt"
                required  />
            </div>
            <div [hidden]="!(editForm.controls.updatedAt?.dirty && editForm.controls.updatedAt?.invalid)">
                <small class="form-text text-danger"
                   [hidden]="!editForm.controls.updatedAt?.errors?.required" jhiTranslate="entity.validation.required">
                   This field is required.
                </small>
                <small class="form-text text-danger"
                    [hidden]="!editForm.controls.updatedAt?.errors?.ZonedDateTimelocal" jhiTranslate="entity.validation.ZonedDateTimelocal">
                    This field should be a date and time.
                </small>
            </div>
        </div>

        <div class="form-group">
            <label jhiTranslate="greatBigExampleApplicationApp.comment.article" for="field_article">Article</label>
            <select class="form-control" id="field_article" name="article" [(ngModel)]="comment.article" >
                <option [ngValue]="null"></option>
                <option [ngValue]="articleOption.id === comment.article?.id ? comment.article : articleOption" *ngFor="let articleOption of articles; trackBy: trackArticleById">{{articleOption.id}}</option>
            </select>
        </div>
        <div class="form-group">
            <label jhiTranslate="greatBigExampleApplicationApp.comment.author" for="field_author">Author</label>
            <select class="form-control" id="field_author" name="author" [(ngModel)]="comment.author" >
                <option [ngValue]="null"></option>
                <option [ngValue]="authorOption.id === comment.author?.id ? comment.author : authorOption" *ngFor="let authorOption of authors; trackBy: trackAuthorById">{{authorOption.id}}</option>
            </select>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal" (click)="clear()">
            <span class="fa fa-ban"></span>&nbsp;<span jhiTranslate="entity.action.cancel">Cancel</span>
        </button>
        <button type="submit" [disabled]="editForm.form.invalid || isSaving" class="btn btn-primary">
            <span class="fa fa-save"></span>&nbsp;<span jhiTranslate="entity.action.save">Save</span>
        </button>
    </div>
</form>
